<?php

namespace app\admin\controller\statistics;

use app\common\controller\Backend;
use app\common\library\Auth;
use think\Db;
use think\Env;

/**
 * 大客户提成统计-查看当月奖励明细
 *
 * @icon fa fa-user
 */
class Datass extends Backend
{


    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];
    protected $relationSearch = true;

    /**
     * @var \app\admin\model\User
     */
    protected $model = null;
    protected $models = null;
    protected $categorylist = [];
    private $redis;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\Datass;
        $this->redis = redis(Env::get('redis.host'), Env::get('redis.port'), Env::get('redis.pwd'), Env::get('redis.db'));
    }

    /**
     * 查看
     */
    public function index()
    {

        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {

            $arr = request()->param();
            //$arr = json_decode(($arr),true);
            $wheres = [];

            if (isset($arr['big_id'])){
                $wheres['big_id'] = $arr['big_id'];
            }

            if (isset($arr['date'])){
                $wheres['date'] = ['between time',[$arr['date'].'-01',$arr['date'].'-31']];
            }

            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $list = $this->model
                //->where($where)
                ->where($wheres)
                ->order('id', 'desc')
                ->paginate($limit);

            $result = array("total" => $list->total(), "rows" => $list->items());

            return json($result);
        }
        return $this->view->fetch();
    }


}
